package org.example.service;

import org.example.dao.IUserDao;
import org.example.domain.User;

import java.util.List;

public class UserServiceImpl implements IUserService {

    private IUserDao userDao;

    public void setUserDao(IUserDao userDao) {
        this.userDao = userDao;
    }

    @Override
    public List<User> list() {
        return userDao.list();
    }

    @Override
    public User get(String id) {
        return userDao.get(id);
    }

    @Override
    public int insert(User user) {
        return userDao.insert(user);
    }

    @Override
    public int update(User user) {
        return userDao.update(user);
    }

    @Override
    public int deleteById(String id) {
        int result = userDao.deleteById(id);

        // 模拟异常，测试事务回滚
        int j = 1 / 0;

        return result;
    }
}
